package cn.jg.framework.auth.model;

import cn.jg.framework.common.model.SimpleBaseTenant;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import lombok.*;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Locale;

/**
 * Created by admin on 2022/04/26.
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@JsonInclude(value = Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class Company extends SimpleBaseTenant {

    private Integer id;

	private static final long serialVersionUID = 1L;

    private String name;
	/**
	 * 对应的udesk系统的id
	 */
	private Integer udeskId;

	/**
	 * 域名
	 */
	private String uri;

	/**
	 * 状态
	 */
	private Integer status;

	private String systemName;

	private String logoUrl;

	private String tagUrl;

	private String kmApiServer;

	private String appId;

	private String openApiAuthToken;

	private Integer ossSecure;

	private String enterpriseEngine;

	private String remoteType;

	/**
	 * NLP模型ID
	 */
	private Integer nlpModelId;

	/**
	 * 租户所在区域
	 */
	@NotEmpty
	private String region;
	/**
	 * 租户所在区域的companyId
	 */
	@NotNull
	private Integer regionCompanyId;
	/**
	 * 租户所在区域的用户中心地址
	 */
	@NotEmpty
	private String ucenterApiServer;

	public Company(Integer id) {
		this.id = id;
	}


    public enum Language {
		CHINESE("ZH-CN"), ENGLISH("EN-US"), JAPANESE("JA-JP"),
		;

		@Getter
		private String value;

		Language(String value) {
			this.value = value;
		}

		public static Locale getLocaleByValue(String val) {
			if (ENGLISH.getValue().equals(val)) {
				return Locale.US;
			}
			if (JAPANESE.getValue().equals(val)) {
				return Locale.JAPAN;
			}
			return Locale.SIMPLIFIED_CHINESE;
		}
	}
}